using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace GameHanhTrinh.FrameWork
{
    public enum ResourceId
    {
        MAINBACKGROUND,
        MENU_BACKGROUND, MENU_PLAY, MENU_CONTINUE, MENU_HIGHSCORE, MENU_EXIT, MENU_TITLE,
        OPTION_TITLE, OPTION_SOUND, OPTION_DIFFICULT
    }
    public enum ResourceMgrId
    {
        RESOURCE_MENU, RESOURCE_GAMEPLAY, RESOURCE_OPTION
    }
    class CResourceManager
    {
        private ResourceMgrId _resourceMgrId;

        private Texture2D _menu_title = null;
        private Texture2D _menu_background = null;
        private Texture2D _menu_play = null;
        private Texture2D _menu_continue = null;
        private Texture2D _menu_highscore = null;
        private Texture2D _menu_exit = null;

        private Texture2D _option_title = null;
        private Texture2D _option_sound = null;
        private Texture2D _option_difficult = null;

        private Texture2D _background = null;

        public CResourceManager(ResourceMgrId resourceMgrId)
        {
            _resourceMgrId = resourceMgrId;
        }

        public void Init(ContentManager CM)
        {
            switch (_resourceMgrId)
            {
                case ResourceMgrId.RESOURCE_MENU:
                    _menu_title = CM.Load<Texture2D>("Texture/Menu/MenuTitle");
                    _menu_background = CM.Load<Texture2D>("Texture/Menu/menu_background");
                    _menu_play = CM.Load<Texture2D>("Texture/Menu/menu_newgame2");
                    _menu_continue = CM.Load<Texture2D>("Texture/Menu/menu_continue2");
                    _menu_highscore = CM.Load<Texture2D>("Texture/Menu/menu_highscore");
                    _menu_exit = CM.Load<Texture2D>("Texture/Menu/menu_exit");
                    break;
                case ResourceMgrId.RESOURCE_GAMEPLAY:
                    _background = CM.Load<Texture2D>("Texture/MainBackground");
                    break;
                case ResourceMgrId.RESOURCE_OPTION:
                    _option_title = CM.Load<Texture2D>("Texture/Option/OptionTitle");
                    _option_sound = CM.Load<Texture2D>("Texture/Option/Option_Sound");
                    _option_difficult = CM.Load<Texture2D>("Texture/Option/Option_Difficult");
                    break;

            }
        }

        public Texture2D GetTexture(ResourceId id)
        {
            switch (id)
            {
                case ResourceId.MENU_BACKGROUND:
                    return _menu_background;
                case ResourceId.MENU_PLAY:
                    return _menu_play;
                case ResourceId.MENU_CONTINUE:
                    return _menu_continue;
                case ResourceId.MENU_HIGHSCORE:
                    return _menu_highscore;
                case ResourceId.MENU_EXIT:
                    return _menu_exit;
                case ResourceId.MAINBACKGROUND:
                    return _background;
                case ResourceId.MENU_TITLE:
                    return _menu_title;
                case ResourceId.OPTION_TITLE:
                    return _option_title;
                case ResourceId.OPTION_SOUND:
                    return _option_sound;
                case ResourceId.OPTION_DIFFICULT:
                    return _option_difficult;
            }
            return null;
        }
    }
}
